use napih::prelude::*;

mod func;

napih::MODULE_INIT!(c"xxx", napih::module_register_noop, module_init);
fn module_init(m: napih::Module) -> napih::Module {
	hilogger::init_default().ok();
	m
}

#[napi_type]
pub type RustType = RustEnum;

#[napi_const]
pub const RUST_CONST: u32 = 8;

#[napi_const]
pub static RUST_STATIC: u32 = 8;

#[napi_const(ty=u32,name=RUST_CONST_FUNC)]
fn const_func(env: &napih::Env) -> napih::Result<'_, napih::Value<'_>> {
	100.into_napi(env)
}

#[napi_class(number)]
pub enum EnumNum {
	Item0 = 0,
	Item1 = 1,
	Item2 = 2,
}

#[napi_class(string)]
pub enum EnumStr {
	Item0,
	Item1,
	Item2,
}

#[napi_class(object)]
pub struct RustObject {
	pub field0: u32,
	pub field1: String,
}

#[napi_class(object)]
pub struct RustObj;

#[napi_class(external)]
pub enum EnumExt {
	Item0,
	Item1,
	Item2,
}

#[test]
fn test() {
	napih::module_dump_dts();
}

#[napi_class]
pub struct RustClass;
#[napi_impl]
impl RustClass {
	#[napi_fn(constructor)]
	pub fn new(_this: napih::Value<'_>, _x: u32, _y: u32) -> Self {
		RustClass
	}
	#[napi_fn]
	pub fn struct_fn0(&self, _xx: u32, _yx: &mut RustEnum, _enum: &RustEnum) {}
	#[napi_fn]
	pub fn struct_fn1(&mut self, _xz: u32, _yz: u32) {
		// _xz.call((), ()).ok();
	}
	#[napi_fn]
	pub fn static_fn(_xssz: u32, _yssz: String) {}
	#[napi_const]
	pub const STRUCT_CONST: u32 = 8;
}

#[napi_class]
pub enum RustEnum {
	Item0,
	Item1,
}
#[napi_impl]
impl RustEnum {
	#[napi_fn(constructor)]
	pub fn new(_this: napih::Value<'_>, _x: u32, _y: u32) -> Self {
		// _x.call(_this, (100, 100)).ok();
		RustEnum::Item0
	}
	#[napi_fn]
	pub fn enum_fn0(&self, _xx: EnumStr, _yx: &mut RustClass) {}
	#[napi_fn]
	pub fn enum_fn1(&mut self, _xz: &EnumExt, _yz: &RustClass) {}
	#[napi_fn]
	pub fn static_fn(_xssz: EnumNum, _yssz: u32) {}
	#[napi_const]
	pub const ENUM_CONST: u32 = 8;
	#[napi_const(ty=u32,name=RUST_ENUM_FUNC)]
	fn func_const(env: &napih::Env) -> napih::Result<'_, napih::Value<'_>> {
		100.into_napi(env)
	}
}

pub mod test_mod {
	// use super::*;
}

// use napi_ohos::bindgen_prelude::new_instance;

// #[napi_derive_ohos::napi]
// pub enum XX {
// 	OO(u32),
// 	XX,
// }

// #[napi_derive_ohos::napi]
// pub struct OO {
// 	pub xx: u32,
// 	pub oo: f64,
// }

// #[napi_derive_ohos::napi]
// impl OO {
// 	#[napi_derive_ohos::napi]
// 	pub fn xx(&self) -> u32 {
// 		self.xx
// 	}
// }

// #[napi_derive_ohos::napi]
// fn xx(x: f64, xx: XX) {}

// #[napi_derive_ohos::napi]
// pub const XX: u32 = 0;

// #[napi_derive_ohos::napi]
// pub type ID = u32;

// #[napi_derive_ohos::napi]
// pub enum OOO {
// 	OO,
// 	XX,
// }
